﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cocos2d;

namespace cocos2d_xna2.Classes
{
    public class MainScene : CCScene
    {

        public static CCScene scene()
        {
            CCScene scene = MainScene.node();
            return scene;
        }

        public bool init()
        {
            if (!base.init())
            {
                return false;
            }


            //CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage(@"images/enemy");

            //CCRect _rect = ccMacros.CCRectMake(40 * 0, 40 * 0, 40, 40);
            //_rect = ccMacros.CC_RECT_POINTS_TO_PIXELS(_rect);

            //// manually add frames to the frame cache
            //CCSpriteFrame frame0 = CCSpriteFrame.frameWithTexture(texture, _rect, false, CCPoint.Zero, _rect.size);

            //_rect = ccMacros.CCRectMake(40 * 1, 40 * 0, 40, 40);
            //_rect = ccMacros.CC_RECT_POINTS_TO_PIXELS(_rect);
            //CCSpriteFrame frame1 = CCSpriteFrame.frameWithTexture(texture, _rect, false, CCPoint.Zero, _rect.size);

            //CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrame(frame0, @"e01");
            //CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrame(frame1, @"e02");


            // 'layer' in OC is an autorelease object.
            // ControlLayer *layer = [ControlLayer node];

            GameLayer glayer = GameLayer.node();
            ControlLayer clayer = ControlLayer.node();
            //glayer.scaleX = 1.5f;
            //glayer.scaleY = 1.5f;
            clayer.Glayer = glayer;

            FireBtn fireBtn = FireBtn.node();
            fireBtn.GLayer = glayer;
            fireBtn.fireActive();

            //添加摇杆
            //Joystick ajoystick = Joystick.node();
            //addChild(ajoystick, 99);            
            //ajoystick.Glayer = glayer;
            //ajoystick.jsActive();


            



            // add layer as a child to scene
            addChild(glayer);
            addChild(clayer);
            //addChild(fireBtn, 99);


            return true;
        }

        public static new MainScene node()
        {
            MainScene scene = new MainScene();

            if (scene.init())
            {
                return scene;
            }
            else
            {
                return null;
            }
        }
    }
}
